import Vue from 'vue';
import App from './App';
import router from './router';
import axios from 'axios';
import ElementUI from 'element-ui';
import 'element-ui/lib/theme-chalk/index.css'; // 默认主题
import "babel-polyfill";
import $ from 'jquery'
import storeConfig from '../vuex/store'
import {
    elDateOpt
} from './components/utils/dateConstant'

/* ueditor 编辑器 */
import '../static/ueditor/ueditor.config.js'
import '../static/ueditor/ueditor.all.min.js'
import '../static/ueditor/lang/zh-cn/zh-cn.js'
import '../static/ueditor/ueditor.parse.min.js'

Vue.use(ElementUI, {
    size: 'small'
});

console.log('this is qing')
console.log(process.env.NODE_ENV)

Vue.prototype.$axios = axios;
// Vue.prototype.$ajaxBase = 'https://braidapi.beiface.com/';
// Vue.prototype.$ajaxBase = 'https://braidapit.beiface.com/';
// Vue.prototype.$ajaxBase = 'https://192.168.10.113:8090/';
let changeUrl = (process.env.NODE_ENV == 'development') ? 'https://braidapit.beiface.com/' : (process.env.NODE_ENV == 'hmbuild') ? 'http://braidapi.henm.cn/' : 'https://braidapi.beiface.com/'

Vue.prototype.$ajaxBase = changeUrl

Vue.prototype.URL_HOST = 'https://'

//使用钩子函数对路由进行权限跳转
// router.beforeEach((to, from, next) => {
//     const role = localStorage.getItem('ms_username');
//     if(!role && to.path !== '/login'){
//         next('/login');
//     }else if(to.meta.permission){
//         // 如果是管理员权限则可进入，这里只是简单的模拟管理员权限而已
//         role === 'admin' ? next() : next('/403');
//     }else{
//         // 简单的判断IE10及以下不进入富文本编辑器，该组件不兼容
//         if(navigator.userAgent.indexOf('MSIE') > -1 && to.path === '/editor'){
//             Vue.prototype.$alert('vue-quill-editor组件不兼容IE10及以下浏览器，请使用更高版本的浏览器查看', '浏览器不兼容通知', {
//                 confirmButtonText: '确定'
//             });
//         }else{
//             next();
//         }
//     }
// })
/* 渠道过滤 */
let getOPTType = (text) => {
    let type = ""
    switch (text) {
        case 'ACTIVATING':
            type = "未跟踪"
            break
        case 'NORMAL':
            type = "跟踪中"
            break
        case 'DISABLED':
            type = "失效"
            break
        case 'WECHAT':
            type = "加微"
            break
        default:
            type = text
    }
    return type
}
Vue.filter('getOPTType', getOPTType)
/* 需求单联系方式过滤 */
let getContactType = (text) => {
    let type = ""
    switch (text) {
        case "PHONE":
            text = "手机"
            break
        case "PHONE_WECHAT":
            text = "手机/微信"
            break
        case "WEHCAT":
            text = "微信"
            break
        case "EMAIL":
            text = "邮箱"
            break
        case "QQ":
            text = "QQ"
            break
    }
    return type
}
Vue.filter('getContactType', getContactType)

/* element-ui日期格式 */
/* 今天 -- 昨天 -- 近7天 -- 近30天 */
Vue.prototype.pickerOptDef = elDateOpt.pickerOptDef
/* 今天 -- 昨天 -- 近7天 -- 近30天 -- 近90天 */
Vue.prototype.pickerOptAll = elDateOpt.pickerOptAll

new Vue({
    router,
    storeConfig,
    render: h => h(App)
}).$mount('#app');